using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ArmemoMap : EntityTypeConfiguration<Armemo>
    {
        public ArmemoMap()
        {
            // Primary Key
            this.HasKey(t => t.ARMEMOID);

            // Properties
            this.Property(t => t.REFERENCE)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.ID)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.DRCR)
                .HasMaxLength(1);

            this.Property(t => t.DESC)
                .HasMaxLength(40);

            this.Property(t => t.ACCT)
                .HasMaxLength(40);

            this.Property(t => t.TYPE)
                .HasMaxLength(2);

            this.Property(t => t.INVNO)
                .HasMaxLength(8);

            this.Property(t => t.BATCH)
                .HasMaxLength(8);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Armemo");
            this.Property(t => t.REFERENCE).HasColumnName("REFERENCE");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.DRCR).HasColumnName("DRCR");
            this.Property(t => t.AMT).HasColumnName("AMT");
            this.Property(t => t.AMTDOL).HasColumnName("AMTDOL");
            this.Property(t => t.AMTVEND).HasColumnName("AMTVEND");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.ACCT).HasColumnName("ACCT");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.PAYERTYPE).HasColumnName("PAYERTYPE");
            this.Property(t => t.TYPE).HasColumnName("TYPE");
            this.Property(t => t.INVNO).HasColumnName("INVNO");
            this.Property(t => t.BATCH).HasColumnName("BATCH");
            this.Property(t => t.POSTED).HasColumnName("POSTED");
            this.Property(t => t.ARMEMOID).HasColumnName("ARMEMOID");
            this.Property(t => t.CSTCTRID).HasColumnName("CSTCTRID");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.TAX).HasColumnName("TAX");

            // Relationships
            this.HasOptional(t => t.Acct1)
                .WithMany(t => t.Armemoes)
                .HasForeignKey(d => d.ACCT);
            this.HasRequired(t => t.Cust)
                .WithMany(t => t.Armemoes)
                .HasForeignKey(d => d.ID);

        }
    }
}
